<?php
session_start();
include_once("conf/CoreConfiguration.inc.php");
include_once("conf/CoreSetting.inc.php");

include_once(LIB_IMPORTER_PATH . DBMS_LIB_IMPORTER_NAME);
include_once(LIB_IMPORTER_PATH . CORE_LIB_IMPORTER_NAME);
include_once(LIB_IMPORTER_PATH . SUPPORT_LIB_IMPORTER_NAME);
include_once(LIB_IMPORTER_PATH . TEMPLATE_LIB_IMPORTER_NAME);
include_once(LIB_IMPORTER_PATH . THEME_LIB_IMPORTER_NAME);


$_SESSIONHANDLER['OVERWRITE_PHP_FUNCTION'] = 0;
$mSession = SIDHandler::GetInstance($_SESSIONHANDLER);

//CHECK: is logged in, dilihat dari apakah $_SESSION user isset?
if (isset($_COOKIE[$_SESSIONHANDLER['SESSION_VAR_NAME']]) && isset($mSession->mVars['User'])) {
    $mLogin = new Logged($mSession);
    $forbidden = false;
    $auth = explode("|", authForbidden);
    $i = 0;
    while ($auth[$i] != "") {
        if ($auth[$i] == $mSession->mVars['User']['Level'])
            $forbidden = true;
        $i++;
    }
    if (!$forbidden) {
        header('Location: main.php');
        exit;
    }
} else {
    $mSession->DestroySession(TRUE);
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <title><?php echo CORE_APPLICATION ?></title>
        <link href="../lib/theme/style/style.theme.login.css" rel="stylesheet" type="text/css" />

        <?php
        foreach ($mIncStyle as $style) {
            echo $style;
        }

        foreach ($mIncJS as $jscript) {
            echo $jscript;
        }
        ?>
    </head>

    <body>
        <?php
        $mTheme = new ThemeBasic();
        //TEST
        $mTheme->PrintLoginPage();
        ?>
    </body>	
</html>